﻿using AntdUI;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace TCOChart
{
    public partial class MenuForm : UserControl
    {
        public MenuForm()
        {
            InitializeComponent();
            BindEventHandler();
        }

        private void BindEventHandler()
        {
            menu1.SelectChanged += Menu_SelectChanged;
        }

        private void Menu_SelectChanged(object sender, MenuSelectEventArgs e)
        {
            string name = (string)e.Value.ID;
            UserControl control = null;
            panel1.Controls.Clear();
            switch (name)
            {
                case "m1":
                    control = new FormPort();
                    panel1.Controls.Add(control);
                    break;
                case "m21":
                    panel1.Controls.Add(null);
                    break;
                case "m22":
                    panel1.Controls.Add(null);
                    break;
            }
        }

        private void button_collapse_Click(object sender, EventArgs e)
        {
            if (menu1.Collapsed)
            {
                menu1.Width = (int)(200 * Config.Dpi);
            }
            else
            {
                menu1.Width = (int)(70 * Config.Dpi);
            }
            button_collapse.Toggle = !button_collapse.Toggle;
            menu1.Collapsed = !menu1.Collapsed;
        }
    }
}
